Welcome to python!

4.13 综合训练:模拟银行账户(3)

#具体业务

while True:

choice=int(input("请输入要办理的业务编号(0.查询 1.转账 2.充值 3.退出)"))

if choice==0:

print(thisAcount)

elif choice==1:

ac=input("请转入转账账户:")

money1=int(input("请转入转账金额:"))

#验证账户

msg2=0 #记录账户是否存在,0表示不存在

for account in acList:

if ac==account["账号"]:

msg2=1

break

if msg==0:

print("账户不存在,请重新选择业务")

continue #退到功能的地方

# 验证金额

if money1>thisAcount["余额"]:

print("余额不足,请重新选择业务编号")

continue

else:

thisAcount["余额"]=thisAcount["余额"]-money1

print("转账成功,转出",money1,"元!余额",thisAcount["余额"],"元")

elif choice==2:

money2=int(input("请转入充值金额:"))

if money2<=0:

print("充值必需大于0,请重新选择业务")

else:

thisAcount["余额"] = thisAcount["余额"] + money2

print("充值成功,充入", money2, "元!余额", thisAcount["余额"], "元")

else:

print("没有此功能,请重新选择")

返回值:

请输入账户名:1002

请输入密码:123

登录成功,您好 李四

请输入要办理的业务编号(0.查询 1.转账 2.充值 3.退出)2

请转入充值金额:190

充值成功,充入 190 元!余额 20190 元

请输入要办理的业务编号(0.查询 1.转账 2.充值 3.退出)